#include "LambertModelRender.h"

LambertModelRender::LambertModelRender(const std::string& name):IRender(name)
{
	mVHandle = ShaderManager::Instance()->CreateShader(ShaderID::SID_LAMBERT_LIGHT_VERTEX);
	ShaderManager::Instance()->LoadShader(mVHandle);
}

void LambertModelRender::draw()
{
	ShaderManager::Instance()->BindShader(mVHandle);
	ShaderManager::Instance()->EnableShaderProfile(mVHandle);
	auto program = ShaderManager::Instance()->GetProgram(mVHandle);
	CGparameter color = cgGetNamedParameter(program, "data.color");
	CGparameter Ia = cgGetNamedParameter(program, "Ia");
	CGparameter LightDir = cgGetNamedParameter(program, "LightDir");
	cgGLSetParameter3f(Ia, 0.8, 0.6, 0.4);
	cgGLSetParameter3f(LightDir, 1, 1, 1);

	glBegin(GL_TRIANGLES);
	cgGLSetParameter4f(color, 1, 1, 1, 1);
	glVertex2f(-0.50f, 0.0f);
	glNormal3f(0, 0, -1);
	
	cgGLSetParameter4f(color, 1, 1, 1, 1);
	glVertex2f(0.50f, 0.0f);
	glNormal3f(0, 0, -1);

	cgGLSetParameter4f(color, 1, 1, 1, 1);
	glVertex2f(0.0f, 0.5f);
	glNormal3f(0, 0, -1);
	glEnd();
	ShaderManager::Instance()->DisableShaderProfile(mVHandle);
	ShaderManager::Instance()->UnBindShader(mVHandle);
}